package com.qssoft.cqry.common.shardingsphere.datasource;

/**
 * @program: cloud-cqry
 * @description:
 * @author: HuaQiao.Deng
 * @create: 2021-01-29 14:46
 */
public class DataSourceContextHolder {
    //默认数据源
    public static final String DEFAULT_DS = "DEFAULT";

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();

    // 设置数据源名
    public static void setDataSourceKey(String dbType) {
        contextHolder.set(dbType);
    }

    // 获取数据源名
    public static String getDataSourceKey() {
        return contextHolder.get();
    }

    // 清除数据源名
    public static void clearDataSourceKey() {
        contextHolder.remove();
    }
}
